首页>代码>Spring实现OAUTH2.0代码DEMO>/OAuth2.0 JAVA服务端和客户端功能实现(带jar包)/sparklr/src/org/springframework/security/oauth/examples/sparklr/mvc/AccessConfirmationController.java
package org.springframework.security.oauth.examples.sparklr.mvc;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

/**
 * Controller for retrieving the model for and displaying the confirmation page for access to a protected resource.
 * 
 * @author Ryan Heaton
 */
@Controller
@SessionAttributes("authorizationRequest")
public class AccessConfirmationController {

	private ClientDetailsService clientDetailsService;

	@RequestMapping("/oauth/confirm_access")
	public ModelAndView getAccessConfirmation(Map<String, Object> model) throws Exception {
		AuthorizationRequest clientAuth = (AuthorizationRequest) model.remove("authorizationRequest");
		ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
		model.put("auth_request", clientAuth);
		model.put("client", client);
		return new ModelAndView("access_confirmation", model);
	}

	@RequestMapping("/oauth/error")
	public String handleError(Map<String,Object> model) throws Exception {
		// We can add more stuff to the model here for JSP rendering.  If the client was a machine then
		// the JSON will already have been rendered.
		model.put("message", "There was a problem with the OAuth2 protocol");
		return "oauth_error";
	}

	@Autowired
	public void setClientDetailsService(ClientDetailsService clientDetailsService) {
		this.clientDetailsService = clientDetailsService;
	}
}
最近下载更多
wubz2008  LV5 2022年3月17日
liu83428190  LV6 2022年3月2日
天险无涯  LV15 2021年10月14日
huangwq  LV1 2021年9月23日
asdsasddas  LV6 2021年1月15日
dongyan1  LV1 2021年1月11日
郭亚钢  LV8 2020年10月8日
qinyt_baosight  LV1 2020年6月19日
binghfengkaier  LV1 2020年5月19日
lyd19931203  LV21 2020年3月26日
最近浏览更多
heartrain  LV3 2023年8月31日
zgxqna 2023年6月1日
暂无贡献等级
CrystalQ  LV8 2022年12月16日
hapsea 2022年7月25日
暂无贡献等级
幸存者hhhhh 2022年7月7日
暂无贡献等级
liu83428190  LV6 2022年3月2日
huangwq  LV1 2021年9月23日
xx1371590378  LV1 2021年6月7日
也会心痛  LV1 2021年3月31日
asdsasddas  LV6 2021年1月15日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友